<!doctype html>



  


<html class="theme-next pisces use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Android,动态加载," />





  <link rel="alternate" href="/atom.xml" title="GrantonZhuang's Blog" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.1" />






<meta name="description" content="上一篇文章中讲到了使用 DexClassLoader 动态加载 dex, jar 或者 apk 文件，再使用加载其中的类实例，使用反射调用需要的方法，或者是强制转型为主项目中的接口，调用接口方法，从而达到动态加载的目的。
在 Android 程序的运行中, Dalvik 虚拟机环境是个相对特殊的环境，最为常见的就是，四大组件和资源等会依赖上下文环境，并不能直接通过 ClassLoader 简单粗暴">
<meta property="og:type" content="article">
<meta property="og:title" content="Android-动态加载进阶-代理Activity和提供资源文件">
<meta property="og:url" content="https://grantonzhuang.github.io/2016/05/28/Android-动态加载进阶-代理Activity/index.html">
<meta property="og:site_name" content="GrantonZhuang's Blog">
<meta property="og:description" content="上一篇文章中讲到了使用 DexClassLoader 动态加载 dex, jar 或者 apk 文件，再使用加载其中的类实例，使用反射调用需要的方法，或者是强制转型为主项目中的接口，调用接口方法，从而达到动态加载的目的。
在 Android 程序的运行中, Dalvik 虚拟机环境是个相对特殊的环境，最为常见的就是，四大组件和资源等会依赖上下文环境，并不能直接通过 ClassLoader 简单粗暴">
<meta property="og:updated_time" content="2016-07-29T13:56:02.584Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Android-动态加载进阶-代理Activity和提供资源文件">
<meta name="twitter:description" content="上一篇文章中讲到了使用 DexClassLoader 动态加载 dex, jar 或者 apk 文件，再使用加载其中的类实例，使用反射调用需要的方法，或者是强制转型为主项目中的接口，调用接口方法，从而达到动态加载的目的。
在 Android 程序的运行中, Dalvik 虚拟机环境是个相对特殊的环境，最为常见的就是，四大组件和资源等会依赖上下文环境，并不能直接通过 ClassLoader 简单粗暴">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: '博主'
    }
  };
</script>




  <link rel="canonical" href="https://grantonzhuang.github.io/2016/05/28/Android-动态加载进阶-代理Activity/"/>

  <title> Android-动态加载进阶-代理Activity和提供资源文件 | GrantonZhuang's Blog </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">GrantonZhuang's Blog</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle"></p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/index.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/index.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/index.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                Android-动态加载进阶-代理Activity和提供资源文件
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-05-28T14:42:38+08:00" content="2016-05-28">
              2016-05-28
            </time>
          </span>

          

          
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>上一篇文章中讲到了使用 DexClassLoader 动态加载 dex, jar 或者 apk 文件，再使用加载其中的类实例，使用反射调用需要的方法，或者是强制转型为主项目中的接口，调用接口方法，从而达到动态加载的目的。</p>
<p>在 Android 程序的运行中, Dalvik 虚拟机环境是个相对特殊的环境，最为常见的就是，四大组件和资源等会依赖上下文环境，并不能直接通过 ClassLoader 简单粗暴地调用，这篇文章主要记录四大组件和资源等动态加载方案的学习成果。</p>
<a id="more"></a>
<h2 id="代理-Activity"><a href="#代理-Activity" class="headerlink" title="代理 Activity"></a>代理 Activity</h2><p>在 Android 开发的第一课里，我们就学过，每一个 Activity 都要在 AndroidManifest.xml 文件里进行注册，否则是不能启动的。</p>
<p>在 Android 开发的第一课里，我们还学过如下的代码：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="meta">@Override</span></div><div class="line"><span class="function"><span class="keyword">protected</span> <span class="keyword">void</span> <span class="title">onCreate</span><span class="params">(Bundle savedInstanceState)</span> </span>&#123;</div><div class="line">    <span class="keyword">super</span>.onCreate(savedInstanceState);</div><div class="line">    setContentView(R.layout.activity_main);</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p><code>onCreate()</code> 方法，我们通常称之为生命周期方法，在系统运行的时候，当前进程会调用当前存在的 Activity 的特定的生命周期方法，但是实际上这些方法也没有什么特殊的地方。</p>
<p>也就是说，如果我们在插件中编写了 Activity, 虽然不能直接 <code>startActivity()</code>, 但是它的生命周期方法，也是可以被反射调用，或者接口调用的，所以出现了这么一个说法，叫做代理 Activity。</p>
<p>思路如下：</p>
<ul>
<li>预先在清单文件中, 注册一个空壳 Activity, 我们称之为 ProxyActivity,</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">activity</span> <span class="attr">android:name</span>=<span class="string">"com.plugin.ProxyActivity"</span> /&gt;</span></div></pre></td></tr></table></figure>
<ul>
<li>定义一个包含需要的生命周期方法的接口，放置在主项目的依赖中。</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">interface</span> <span class="title">Plugin</span> </span>&#123;</div><div class="line">    <span class="function"><span class="keyword">void</span> <span class="title">onResume</span><span class="params">()</span></span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<ul>
<li>在插件项目中，实现这个接口，实现对应的生命周期方法，尽管生命周期方法和接口方法同名，但是不冲突。</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">package</span> com.plugin.LogicActivity</div><div class="line"></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">LogicActivity</span> <span class="keyword">extends</span> <span class="title">Activity</span> <span class="keyword">implements</span> <span class="title">Plugin</span> </span>&#123;</div><div class="line">    <span class="meta">@Override</span></div><div class="line">    <span class="function"><span class="keyword">void</span> <span class="title">onResume</span><span class="params">()</span> </span>&#123;</div><div class="line">        <span class="comment">// do some thing</span></div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<ul>
<li>编写 ProxyActivity，我们根据业务需要，动态加载需要的 Activity，推荐以接口形式。</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">ProxyActivity</span> <span class="keyword">extends</span> <span class="title">Activity</span> </span>&#123;</div><div class="line">    <span class="function"><span class="keyword">void</span> <span class="title">loadActivity</span><span class="params">()</span> </span>&#123;</div><div class="line">        Class&lt;?&gt; activityClass = classLoader.loadClass(<span class="string">"com.plugin.LogicActivity"</span>);</div><div class="line">        Constructor&lt;?&gt; constructor = activityClass.getConstructor(<span class="keyword">new</span> Class[] &#123;&#125;);</div><div class="line">        Object instance = constructor.newInstance(<span class="keyword">new</span> Object[] &#123;&#125;);</div><div class="line">        mPlugin = (Plugin)instance;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    <span class="meta">@Overrdie</span></div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">onResume</span><span class="params">()</span> </span>&#123;</div><div class="line">        mPlugin.onResume();</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>同样，对于 service, 也采用这种思路。</p>
<h2 id="资源文件的访问"><a href="#资源文件的访问" class="headerlink" title="资源文件的访问"></a>资源文件的访问</h2><p>通过代理 Activity 的方式，我们可以在代理 Activity 中做到调用插件 Activity 的生命周期方法，那么另外一个问题，如何在主项目中访问插件项目中的资源文件呢？</p>
<blockquote>
<p>首先我们来看，常规手段访问资源的过程。</p>
</blockquote>
<ul>
<li>比如在 Activity 中获取一个字符串资源，我们正常的使用方法是这样子的：</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">String str = getString(R.string.strId);</div></pre></td></tr></table></figure>
<p>那么 Activity 的 getString() 方法的具体实现呢？在父类 Context 中。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="meta">@NonNull</span></div><div class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">final</span> String <span class="title">getString</span><span class="params">(@StringRes <span class="keyword">int</span> resId)</span> </span>&#123;</div><div class="line">    <span class="keyword">return</span> getResources().getString(resId);</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<blockquote>
<p>通过 Resource 对象获取。</p>
</blockquote>
<ul>
<li>又或者是设置布局文件</li>
</ul>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">setContentView(R.id.layoutID);</div></pre></td></tr></table></figure>
<p>在 Activity 中的源码：<br><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setContentView</span><span class="params">(@LayoutRes <span class="keyword">int</span> layoutResID)</span> </span>&#123;</div><div class="line">    getWindow().setContentView(layoutResID);</div><div class="line">    initWindowDecorActionBar();</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>这里的 getWindow() 返回的是 Activity 的成员变量 mWindow</p>
<p>mWindow 在 attach() 方法中被初始化</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">mWindow = <span class="keyword">new</span> PhoneWindow(<span class="keyword">this</span>);</div></pre></td></tr></table></figure>
<p>PhoneWindow 的 setContentView() 方法<br><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line"><span class="meta">@Override</span></div><div class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setContentView</span><span class="params">(<span class="keyword">int</span> layoutResID)</span> </span>&#123;</div><div class="line">    <span class="comment">// ...</span></div><div class="line">    <span class="keyword">if</span> (hasFeature(FEATURE_CONTENT_TRANSITIONS)) &#123;</div><div class="line">        <span class="keyword">final</span> Scene newScene = Scene.getSceneForLayout(mContentParent, layoutResID, getContext());</div><div class="line">        transitionTo(newScene);</div><div class="line">    &#125; <span class="keyword">else</span> &#123;</div><div class="line">        mLayoutInflater.inflate(layoutResID, mContentParent);</div><div class="line">    &#125;</div><div class="line">    <span class="comment">// ...</span></div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>无论是缓存中是否存在 Scene 实例，最后都会将传入的 layoutResID 通过 LayoutInflater 加载这个布局。</p>
<p>那么我们看 <code>LayoutInflater$inflate()</code> 方法:</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">public</span> View <span class="title">inflate</span><span class="params">( @LayoutRes <span class="keyword">int</span> resource, @Nullable ViewGroup root, <span class="keyword">boolean</span> attachToRoot)</span> </span>&#123;</div><div class="line">    <span class="keyword">final</span> Resources res = getContext().getResources();</div><div class="line">    <span class="keyword">final</span> XmlResourceParser parser = res.getLayout(resource);</div><div class="line">    <span class="keyword">try</span> &#123;</div><div class="line">        <span class="keyword">return</span> inflate(parser, root, attachToRoot);</div><div class="line">    &#125; <span class="keyword">finally</span> &#123;</div><div class="line">        parser.close();</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<blockquote>
<p>依旧是 Resources 对象</p>
</blockquote>
<p>不管是设置布局还是获取字符串资源，都是先通过 <code>Context$getResources()</code> 获取到 Resources 对象，（实际上 图片资源，像素大小等也一样），我们看 Resources 和 Context 之间的关系。</p>
<p>在 Context 的实现 ContextImpl 的构造函数中，我们看到这样一段代码</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line"><span class="function"><span class="keyword">private</span> <span class="title">ContextImpl</span><span class="params">(many many args...)</span> </span>&#123;</div><div class="line">    <span class="comment">// ...</span></div><div class="line">    Resources resources = packageInfo.getResources(mainThread);</div><div class="line">    <span class="keyword">if</span> (resources != <span class="keyword">null</span>) &#123;</div><div class="line">        <span class="keyword">if</span> (many many 条件) &#123;</div><div class="line">            resources = mResourcesManager.getTopLevelResources(many many args);</div><div class="line">    	&#125;</div><div class="line">    &#125;</div><div class="line">    mResources = resources;</div><div class="line">    <span class="comment">// ...</span></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>再深入 getTopLevelResources() 方法，会发现一个结果，在这个方法里，会创建一个 AssetManager 实例，并且用该 AssetManager 实例根据路径加载资源文件，最后如下构造函数来构建一个 Resources 实例：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line"><span class="comment">/**</span></div><div class="line"> * Creates a new Resources object with CompatibilityInfo.</div><div class="line"> *</div><div class="line"> * <span class="doctag">@param</span> assets Previously created AssetManager.</div><div class="line"> * <span class="doctag">@param</span> metrics Current display metrics to consider when</div><div class="line"> *                selecting/computing resource values.</div><div class="line"> * <span class="doctag">@param</span> config Desired device configuration to consider when</div><div class="line"> *               selecting/computing resource values (optional).</div><div class="line"> * <span class="doctag">@param</span> compatInfo this resource's compatibility info. Must not be null.</div><div class="line"> * <span class="doctag">@hide</span></div><div class="line"> */</div><div class="line"><span class="function"><span class="keyword">public</span> <span class="title">Resources</span> <span class="params">( AssetManager assets, DisplayMetrics metrics,</span></span></div><div class="line">    Configuration config, CompatibilityInfo compatInfo ) &#123; &#125;</div></pre></td></tr></table></figure>
<p>所以我们可以通过如下代码来访问到插件中的资源文件<br><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">try</span> &#123;</div><div class="line">    AssetManager assetManager = AssetManager.class.newInstance();</div><div class="line">    <span class="comment">// 该方法在实际上的手机系统中为私有，所以需要使用反射调用</span></div><div class="line">    Method addAssetPath = assetManager.getClass().getMethod(<span class="string">"addAssetPath"</span>, String.class);</div><div class="line">    <span class="comment">// 加载资源文件</span></div><div class="line">    addAssetPath.invoke(assetManager, mDexPath);</div><div class="line">    mAssetManager = assetManager;</div><div class="line">&#125; <span class="keyword">catch</span> (Exception e) &#123;</div><div class="line">    e.printStackTrace();</div><div class="line">&#125;</div><div class="line"><span class="comment">// 主项目的 Resources 对象和这里构造出来的 Resources 相互之间是没有关系的</span></div><div class="line"><span class="comment">// 只是借助主项目的一些信息如 Configuration DisplayMetrics 等构造这个新的 Resources 对象</span></div><div class="line">pluginResources = <span class="keyword">new</span> Resources( mAssetManager, getResources().getDisplayMetrics(), getResources().getConfiguration());</div></pre></td></tr></table></figure></p>
<p>至此，访问插件中的资源文件的问题也有了一个解决的方案。</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Android/" rel="tag">#Android</a>
          
            <a href="/tags/动态加载/" rel="tag">#动态加载</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/05/26/使用nexus搭建maven仓库/" rel="next" title="使用nexus搭建maven仓库">
                <i class="fa fa-chevron-left"></i> 使用nexus搭建maven仓库
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2016/06/05/Android 动态加载 so 库学习笔记/" rel="prev" title="Android 动态加载 so 库学习笔记">
                Android 动态加载 so 库学习笔记 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="http://ww1.sinaimg.cn/mw690/6e8939a6gw1f3g1u1mc6lj20hs0hsmxf.jpg"
               alt="Granton Zhuang" />
          <p class="site-author-name" itemprop="name">Granton Zhuang</p>
          <p class="site-description motion-element" itemprop="description"></p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives/index.html">
              <span class="site-state-item-count">26</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">11</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#代理-Activity"><span class="nav-number">1.</span> <span class="nav-text">代理 Activity</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#资源文件的访问"><span class="nav-number">2.</span> <span class="nav-text">资源文件的访问</span></a></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Granton Zhuang</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>

        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.1"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.0.1"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.1"></script>



  



  




  
  

  

  

  

</body>
</html>
